<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 数据代理：
        var name = 'atguigu';
        var user = {
            age: 19,
            get name() {
                console.log('获取name的值');
                return name;
            },
            set name(val) {
                console.log('name 的 setter执行了：', val);
                name = val;
            }
        }

        // console.log(user.age);
        // console.log(user.name);

        // user.age = 29;
        // user.name = '尚硅谷';

        console.log(user.name);

        user.name = '尚硅谷';
        console.log(user.name);

        console.log('user: ', user);





    </script>
</body>

</html>